<?php


namespace app\observ;


class ConcreteSubject implements Subject
{
    private $observers = [];

    public function registerObserver(Observer $observer)
    {
        $this->observers[md5(serialize($observer))] = $observer;
    }

    public function removeObserver(Observer $observer)
    {
        unset($this->observers[md5(serialize($observer))]);
    }

    public function notify($message)
    {
        foreach ($this->observers as $observer) {
            $observer->update($message);
        }
    }
}